
from xml import sax

class OutlineHandler(sax.handler.ContentHandler):
    def __init__(self):
        self.channels = []

    def startElement(self, name, attrs):
        if name == 'outline' and 'type' in attrs and attrs['type'] == 'rss':
            self.channels.append({ 'link' : attrs['xmlUrl'], 'title' : attrs['text'] })

def parse(string):
    handler = OutlineHandler()
    sax.parseString(string, handler)
    return handler.channels
